package com.woniuxy.education.controller;

import com.woniuxy.education.entity.DataInformation;
import com.woniuxy.education.entity.TeacherInformation;
import com.woniuxy.education.service.SelectTeacherDataService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@CrossOrigin
@RestController
@Controller
public class TeacherInformationController {
    @Autowired
    SelectTeacherDataService selectTeacherDataService;
    @RequestMapping("/selectTeacherData")
    public TeacherInformation selectTeacherData(String username){

        TeacherInformation tf=new TeacherInformation();
        tf=selectTeacherDataService.selectTinformation(username);
        tf.setUsername(username);

       return tf;
    }
    @RequestMapping("/selectTeacherData1")
    public void selectTeacherData1(String name,String tel){

        System.out.println(name);
        System.out.println(tel);
        selectTeacherDataService.update(name, tel);

    }
    //
    @RequestMapping("/selectTeacherData2")
    public DataInformation selectTeacherData2(String username,String oldpassword,String newpassword){
        System.out.println(username);
        System.out.println(oldpassword);
        System.out.println(newpassword);
        DataInformation d=selectTeacherDataService.updatePassword(username, oldpassword, newpassword);

        return d;
    }

}
